﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DistributeRole.aspx.cs" Inherits="DistributeRole" %>

<%@ Register Src="RoleRight.ascx" TagName="RoleRight" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.3.2.min.js"></script>
   <script>
       $(document).ready(function () {
           $("#btnBack").click(function () {
               alert();
               document.location = "default.aspx";
           })
       })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="float: left; width: 99%; height: 30px; background-color: #66ccff">
        <b>分配角色权限</b></div>
    <div style="width: 99%; background-color: #b4e5fd; text-align: left">
        &nbsp;权限分配<font color="red">(选定后保存) &nbsp; &nbsp; &nbsp;</font><strong>当前角色 -&gt;</strong><span
            id="ctl00_ContentPlaceHolder1_lblCurrentRole" style="display: inline-block; font-weight: bold;
            width: 125px"><asp:Label ID="lblRoleName" runat="server" Text=""></asp:Label></span></div>
    <div style="width: 99%; background-color: #b4e5fd">
        <asp:DataList ID="table" runat="server" OnItemDataBound="DataList1_ItemDataBound">
            <ItemTemplate>
                <uc1:RoleRight ID="RoleRight1" runat="server" Pid='<%# Eval("id") %>' />
            </ItemTemplate>
        </asp:DataList>
    </div>
    <br />
    <br />
    <div>
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp;&nbsp;
        <asp:Button ID="btnSave" runat="server" Text="提交" CssClass="common_button" OnClick="btnSave_Click" />
        &nbsp; &nbsp; &nbsp; &nbsp;
        <input id="btnBack" class="common_button"  style="width: 45px; cursor: hand;
            height: 19px" type="button" value="返回" /></div>
    <script>
        $(document).ready(function () {
            $("input[type=checkbox]").click(
                function () {
                    if ($(this).parent("span").attr("tt") == "aa") {
                        var table = $(this).parent().parent("div").children("table");
                        var inputs = table.children().children("tr").children("td").children("input[type=checkbox]");
                        for (var i = 0; i < inputs.length; i++) {
                            inputs[i].checked = this.checked;
                        }
                    }
                    else {
                        var pcheck = $(this).parent().parent().parent().parent().parent().children("span").children("input[type=checkbox]")[0];
                        var inputs = $(this).parent().parent().children("td").children("input[type=checkbox]");
                        var result = false;
                        for (var i = 0; i < inputs.length; i++) {
                            if (inputs[i].checked) {
                                result = true;
                            }
                        }
                        pcheck.checked = result;
                    }
                }
               )
        })   
		
        
    </script>
    </form>
</body>
</html>
